package com.yyn.educms.controller;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yyn.R;
import com.yyn.educms.entity.CrmBanner;
import com.yyn.educms.service.CrmBannerService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 首页banner表 前端控制器
 * </p>
 *
 * @author yyn
 * @since 2023-01-02
 */
@RestController
@CrossOrigin
@RequestMapping("/educms/bannerFront")
public class CrmBannerFrontController {
    @Autowired
    CrmBannerService crmBannerService;
    //    查所有
    @ApiOperation("查所有")
    @GetMapping("getAll")
    @Cacheable(value = "banner",key="'selectIndexList'")
    public R getAllBanner(){
        LambdaQueryWrapper<CrmBanner> crmBannerLambdaQueryWrapper = new LambdaQueryWrapper<>();
        crmBannerLambdaQueryWrapper.orderByDesc(CrmBanner::getId);
        crmBannerLambdaQueryWrapper.last("limit 2");
        List<CrmBanner> list = crmBannerService.list();
        return R.success().data("all",list);
    }
}

